package cn.tedu.hospital.admin.server.patient.dao.persist.repository.impl;

import cn.tedu.hospital.admin.server.patient.dao.persist.mapper.PatientDetailMapper;
import cn.tedu.hospital.admin.server.patient.dao.persist.repository.IPatientDetailRepository;
import cn.tedu.hospital.admin.server.patient.pojo.entity.PatientDetail;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

/**
 * 处理患者详情数据的存储库实现类
 *
 * @author java@tedu.cn
 * @version 1.0
 */
@Slf4j
@Repository
public class PatientDetailRepositoryImpl implements IPatientDetailRepository {

    @Autowired
    private PatientDetailMapper patientDetailMapper;

    public PatientDetailRepositoryImpl() {
        log.info("创建存储库对象：ArticleDetailRepositoryImpl");
    }

    @Override
    public int insert(PatientDetail patientDetail) {
        log.debug("开始执行【插入患者详情】的数据访问，参数：{}", patientDetail);
        return patientDetailMapper.insert(patientDetail);
    }

    @Override
    public int deleteByPatientId(String patientId) {
        log.debug("开始执行【根据患者ID删除患者详情数据】的数据访问，参数：{}", patientId);
        QueryWrapper<PatientDetail> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("patient_id", patientId);
        return patientDetailMapper.delete(queryWrapper);
    }

    @Override
    public int updateByArticle(PatientDetail patientDetail) {
        log.debug("开始执行【更新患者详情】的数据访问，参数：{}", patientDetail);
        QueryWrapper<PatientDetail> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("patientId", patientDetail.getPatientId());
        return patientDetailMapper.update(patientDetail, queryWrapper);
    }

}